﻿using System;
using System.Collections.Generic;
using UnityEngine;

public class MapNode
{
    private SpriteRenderer spriteRenderer;

    private Transform goTrans;

    /// <summary>
    /// 表示 格子的类型
    /// </summary>
    public int iType { get; set; }

    private float fX;

    private float fY;

    public float X
    {
        get { return fX; }
    }

    public float Y
    {
        get { return fY; }
    }

    public void Init(GameObject go)
    {
        this.goTrans = go.transform;
        spriteRenderer = go.GetComponent<SpriteRenderer>();
    }

    public void SetSprite(Sprite s)
    {
        if (s == null) return;
        spriteRenderer.sprite = s;
    }

    public void SetParent(Transform t)
    {
        goTrans.SetParent(t, false);
    }

    public void SetXY(float fX, float fY)
    {
        this.fX = fX;
        this.fY = fY;
        goTrans.localPosition = new Vector3(fX,0,fY);
    }

    public void SetActive(bool bActive)
    {
        goTrans.gameObject.SetActive(bActive);
    }

    public void Release()
    {
        if (goTrans != null)
        {
            GameObject.DestroyImmediate(goTrans.gameObject);
        }
    }
}
